<template>
	<view>
		<view v-html="product.chanpxq"></view>
		<!-- 吸底按钮 -->
		<!-- <div class="clear h60"></div> -->
		<!-- <button @click="submitForm" class="btn-red bottom-btn border-no">保费试算</button> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				product: ""
			}
		},
		
		onShareAppMessage() {
			let openId = "";
			if(uni.getStorageSync("openId") != null)
				openId = uni.getStorageSync("openId").openid
				
			return {
			  title: this.product.chanpmc,
			  path: 'pages/productDetail/productDetail?id=' + product.id + '&shareBy=' + openId,
			  imageUrl: this.product.chanpzt
			}
		},
		
		onLoad(option) {
			let that = this
			
			if(uni.getStorageSync('openId') == null || uni.getStorageSync('openId') == "") {
				uni.login({
					provider: 'weixin',
					success: loginRes => {
						uni.request({
							url: getApp().globalData.serviceUrl + "/weixin/getOpenIdByCode",
							dataType: 'json',
							method: 'GET',
							data: {
								code: loginRes.code
							},
							success: (result) => {
								if (result.data.success) {
									uni.setStorageSync('openId', result.data.result)
									if(option.shareBy)
										that.jianlixygx(option.shareBy)
								}
									
							}
						});
					}
				});
			}
			
			uni.request({
				url: getApp().globalData.serviceUrl + "/chanp/kuybChanp/queryById",
				data: {
					id: option.productId
				},
				method: 'GET',
				success: (resp) => {
					if (resp.data.success) {
						uni.setStorageSync("product", resp.data.result)
						
						if(resp.data.result != "")
							that.product = resp.data.result
					}
				},
				complete() {
					uni.hideLoading()
				}
			});
			
		},
		
		methods: {
			jianlixygx(shareBy) {
				uni.request({
					url: getApp().globalData.serviceUrl + "/myteam/kuybTeam/bloodRelationship",
					data: {
						shareBy: shareBy,
						myOpenId: uni.getStorageSync('openId').openid
					},
					method: 'GET',
					success: (resp) => {
						if (resp.data.success) {
							
						}
					}
				});
				
			},
			
			submitForm() {
				uni.navigateTo({
					url: '../../pages2/baofShis/baofShis'
				})
			}
		}
	}
</script>

<style>

</style>
